package com.hmall.search.controller;

import java.util.List;

import com.hmall.search.domain.dto.ItemDoc;
import com.hmall.search.service.SearchService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: suren@517na.com
 * @CreateTime: 2025-04-07
 * @Description: 查询controller
 */

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @ApiOperation("根据id批量查询商品")
    @GetMapping
    public List<ItemDoc> queryItemByIds(@RequestParam("ids") List<Long> ids) {
        return searchService.queryItemByIds(ids);
    }

    @ApiOperation("根据id查询商品详情")
    @GetMapping("{id}")
    public ItemDoc queryItemById(@PathVariable("id") Long id) {
        return searchService.queryItemById(id);
    }
}
